import request from '../utils/request'
import config from '../config'
import wepy from 'wepy'

/*
 * 产品页接口
 * @author： 黄
 */

/*
 * @desc 获取产品列表
 * @param {object} filter 筛选对象
 * @return {promise}
 */
async function getGoodsList (filter) {
  filter = filter || []
  let userInfo = wepy.getStorageSync('userInfo')
  filter.shopid = filter.shopid || userInfo.departmentid
  return request(config.apiList.getGoodsList, filter)
}

/*
 * @desc 获取单个项目
 * @param {number} id 项目id
 * @return {object} subject
 */
async function getGoodsInfo (id) {
  return request(config.apiList.getGoodsInfo, {id: id})
}

export {
  getGoodsList,
  getGoodsInfo
 }
